using System.Collections;
using UnityEngine;

public class PlayerState_斩棍式 : PlayerStateBase
{
	private Coroutine _Cor_动作中向前力;

	public PlayerState_斩棍式()
	{
		_Data_Player招式_系数 = MonoSingleton<MyDataManager>.Instance._Data_玩家招式._斩棍式;
	}

	public override void OnEnter()
	{
		_Mono.F_玩家转向(Input.GetAxisRaw("Horizontal"));
		_Mono._Ani.Play("斩棍式");
		_Mono._可以受击 = false;
		_Cor_动作中向前力 = _Mono.StartCoroutine(Cor_动作中向前力());
		_Timer = _Mono._Dict_AniName_time["斩棍式"];
		_NextState = StateType_Player.正常移动;
		_Mono._C_攻击判断._击退力度 = 6f;
		F_创建攻击命中回调();
	}

	public override void F_攻击命中回调()
	{
		_Mono._Curr豆子++;
		_Mono._Curr蓄力 += _Data_Player招式_系数._棍势值;
	}

	public override void OnExit()
	{
		_Mono._C_攻击判断._攻击命中回调 -= F_攻击命中回调;
		if (_Cor_动作中向前力 != null)
		{
			_Mono.StopCoroutine(_Cor_动作中向前力);
			_Cor_动作中向前力 = null;
		}
		_Mono._可以受击 = true;
	}

	public override void OnUpdate()
	{
		base.OnUpdate();
	}

	private IEnumerator Cor_动作中向前力()
	{
		_Mono._Rb2D.velocity = Vector2.zero;
		_Mono._Rb2D.AddForce(new Vector2((_Mono._朝向右边 ? 1 : (-1)) * 30, 0f), ForceMode2D.Impulse);
		yield return new WaitForSeconds(0.3f);
		_Mono._Rb2D.AddForce(new Vector2((_Mono._朝向右边 ? 1 : (-1)) * 40, 0f), ForceMode2D.Impulse);
		yield return new WaitForSeconds(0.1f);
		_Mono._Rb2D.AddForce(new Vector2((_Mono._朝向右边 ? 1 : (-1)) * 20, 0f), ForceMode2D.Impulse);
	}
}
